﻿Imports System.Data
Imports FirebirdSql.Data
Imports FirebirdSql.Data.FirebirdClient
Public Class _experienciaProfissional
    Inherits _DataBase

    Private _idExperienciaProf As Integer
    Public Property idExperienciaProf() As Integer
        Get
            Return _idExperienciaProf
        End Get
        Set(ByVal value As Integer)
            _idExperienciaProf = value
        End Set
    End Property
    Private _idTrabalhador As Integer
    Public Property idTrabalhador() As Integer
        Get
            Return _idTrabalhador
        End Get
        Set(ByVal value As Integer)
            _idTrabalhador = value
        End Set
    End Property
    Private _nmEmpresa As String
    Public Property nmEmpresa() As String
        Get
            Return _nmEmpresa
        End Get
        Set(ByVal value As String)
            _nmEmpresa = value
        End Set
    End Property
    Private _dsAtividade As String
    Public Property dsAtividade() As String
        Get
            Return _dsAtividade
        End Get
        Set(ByVal value As String)
            _dsAtividade = value
        End Set
    End Property
    Private _idCargoFuncao As Integer
    Public Property idCargoFuncao() As Integer
        Get
            Return _idCargoFuncao
        End Get
        Set(ByVal value As Integer)
            _idCargoFuncao = value
        End Set
    End Property
    Private _dtInicio As Date
    Public Property dtInicio() As Date
        Get
            Return _dtInicio
        End Get
        Set(ByVal value As Date)
            _dtInicio = value
        End Set
    End Property
    Private _dtFim As Date
    Public Property dtFim() As Date
        Get
            Return _dtFim
        End Get
        Set(ByVal value As Date)
            _dtFim = value
        End Set
    End Property
    Private _dsPeriodoMes As String
    Public Property dsPeriodoMes() As String
        Get
            Return _dsPeriodoMes
        End Get
        Set(ByVal value As String)
            _dsPeriodoMes = value
        End Set
    End Property


    Public Sub insereExperienciaProf()

        conectaDb()
        execSQLSemRetorno(montaParametrosSQL("SP_EXPERIENCIAPROFISSIONAL_CMD", "INSERIR"))
        desconectaDb()

    End Sub

    Public Function consultaExperienciaPorTrabalhador(ByVal pIdTrabalhador As Integer) As DataSet

        conectaDb()
        idTrabalhador = pIdTrabalhador
        consultaExperienciaPorTrabalhador = retornaDataSet(montaParametrosSQL("SP_EXPERIENCIAPROF_CONSULTA", "IDTRAB"))
        desconectaDb()

    End Function

    Public Sub excluiExperienciaTrabalhador(ByVal pIdExperiencia As Integer)
        conectaDb()
        idExperienciaProf = pIdExperiencia
        execSQLSemRetorno(montaParametrosSQL("SP_EXPERIENCIAPROFISSIONAL_CMD", "DELETAR"))
        desconectaDb()

    End Sub
    Public Sub alteraExperienciaTrabalhador(ByVal pIdExperiencia As Integer)
        idExperienciaProf = pIdExperiencia
        conectaDb()
        execSQLSemRetorno(montaParametrosSQL("SP_EXPERIENCIAPROFISSIONAL_CMD", "ALTERAR"))
        desconectaDb()
    End Sub

    Private Function montaParametrosSQL(ByVal nomeSP As String, ByVal pModo As String) As FbCommand
        With cmd
            .CommandText = nomeSP
            With .Parameters
                .Clear()
                .Add("MODO", FbDbType.VarChar, 10).Value = pModo
                .Add("I_id_experiencia", FbDbType.Integer).Value = idExperienciaProf
                .Add("I_ID_TRABALHADOR", FbDbType.Integer).Value = idTrabalhador
                .Add("I_NM_EMPRESA", FbDbType.VarChar, 60).Value = nmEmpresa
                .Add("I_DS_ATIVIDADES", FbDbType.VarChar, 150).Value = dsAtividade
                .Add("I_ID_CARGOFUNCAO", FbDbType.Integer).Value = idCargoFuncao
                .Add("I_DS_PERIODOMES", FbDbType.VarChar, 30).Value = dsPeriodoMes



            End With
        End With
        Return cmd

    End Function


End Class
